package de.web.gui;

import javax.servlet.ServletContext;

import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import de.preisrobot.persistence.dao.AnbieterDao;
import de.web.gui.model.AnbieterDataProvider;

public class AnbieterApplication extends WebApplication
{

   @Override
   public Class<? extends Page> getHomePage()
   {
      return AnbieterGui.class;
   }

   private AnbieterDao getAnbieterDao()
   {
      ServletContext servletContext = getServletContext();//.getSpringContext().getBean("contactDao")
      WebApplicationContext wac = WebApplicationContextUtils.
      getRequiredWebApplicationContext(servletContext);
      
      AnbieterDao anbieteDao = (AnbieterDao) wac.getBean("anbieterDao");
      return anbieteDao;
   }
   
   public AnbieterDataProvider getAnbieterDataProvider()
   {
      AnbieterDataProvider p = new AnbieterDataProvider();
      p.setDao(getAnbieterDao());
      return p;
   }

}
